#!/data/data/com.termux/files/usr/bin/bash
DIR=$(
  cd $(dirname $0)
  pwd
)
COLORS_DIR=$DIR/colors
count=0

echo -e "The default color scheme is monokai dark.\nYou can choose another one from the list below"
echo '您可以在此列表中选择终端配色。'
for colors in "$COLORS_DIR"/*; do
  colors_name[count]=$(echo $colors | awk -F'/' '{print $NF}')
  echo -e "($count) ${colors_name[count]}"
  count=$(($count + 1))
done
count=$(($count - 1))

while true; do
  read -p '请输入选项数字,并按回车键,留空不更改。Please type the option number and press Enter:' number
  if [[ -z "$number" ]]; then
    break
  elif ! [[ $number =~ ^[0-9]+$ ]]; then
    echo "Please enter the right number!"
  elif (($number >= 0 && $number <= $count)); then
    eval choice=${colors_name[number]}
    cp -fr "$COLORS_DIR/$choice" "$DIR/colors.properties"
    break
  else
    echo "Please enter the right number!"
  fi
done

termux-reload-settings
